#include "SemanticUtil/RdfStore.h"
#include "FwdRule.h"
#include <vector>

#ifndef _INFERENCEMODEL_H_
#define _INFERENCEMODEL_H_

enum ErrorCode {
	ErrorNone = 0x0, /**< No error occured, i.e. success. */
	ErrorInvalidArgument = 0x1, /**< Error indicating that a method argument was invalid. For example an invalid Statement in Model::addStatement(). */
	ErrorInvalidStatement = ErrorInvalidArgument, /**< \deprecated: use ErrorInvalidArgument */
	ErrorNotSupported = 0x2, /**< Error indicating that a certain functionality is not supported. */
	ErrorParsingFailed = 0x3, /**< Parsing a query or an RDF serialization failed. */
	ErrorPermissionDenied = 0x4, /**< Permission is denied. \since 2.1 */
	ErrorTimeout = 0x5, /**< The command timed out. \since 2.7.4 */
	ErrorUnknown = 0x1000
/**< An unknown error occured. */
};

class InferenceModel{
public:
	InferenceModel();
	~InferenceModel();

	ErrorCode addStatement(Statement state);
	ErrorCode removeStatement(Statement state);
	ErrorCode removeAllStatement(Statement state);
	void addRule(FwdRule rul);
	void setRules(QList<FwdRule> rules);

	void performInference();

    /**
     * If compressed statements are enabled source statements are stored compressed
     * in one literal value. Otherwise source statements are stored using rdf:subject,
     * rdf:predicate, rdf:object, and sil:context. Non-compressed statements are much
     * cleaner from an ontology design point of view while compressed statements take
     * much less space.
     *
     * By default comressed source statements are enabled.
     *
     * This method exists mainly for historical reasons and there normally is no need
     * to call it. Compressed statements should work well for most users.
     *
     * \param b If true compressed source statements are enabled (the default).
     */
    void setCompressedSourceStatements( bool b );

	void setOptimizedQueriesEnabled( bool b );

public:
    /**
     * Create all infered statements that result from adding statement. Calls inferRule.
     *
     * \param statement The new statement, only matching rules will be recalculated.
     * \param recurse If true inferred statements will recursively triggeer inferStatement.
     *
     * \return the number of new statements infered.
     */
    int inferStatement( Statement statement, bool recurse = false );

    /**
     * Create all infered statements that result from applying rule to the model.
     *
     * \param rule The rule to apply.
     * \param recurse If true inferred statements will recursively triggeer inferStatement.
     *
     * \return the number of new statements infered.
     */
    int inferRule( FwdRule& rule, bool recurse );


    std::vector<Statement> getInferedStatement();

public: //类变量
    QList<FwdRule> rules;
    bool compressedStatements;
    bool optimizedQueries;
    std::vector<Statement> inferedStatement_toSend;
};
#endif //_INFERENCEMODEL_H_
